package com.lin.start;

import com.corundumstudio.socketio.SocketIOServer;
import com.lin.config.SpringContextIniter;
import com.lin.properties.ConsumeProperties;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;

@Configuration
@Component
public class NettyApplicationRunner implements ApplicationRunner {
    protected static Logger log = LoggerFactory.getLogger(NettyApplicationRunner.class);

//    public static final String NAMESPACE_ = "/chat1";//构建命名空间
    @Autowired
    private SocketIOServer socketIOServer;

    @Override
    public void run(ApplicationArguments args) throws Exception {
//        socketIOServer.start();

    }


//    @PreDestroy
//    private void autoStop() throws Exception {
//        log.info("stop socketIOServer");
////        SocketIOServer ss =SocketServerFactory.getInstance();
//        // 避免重启项目服务端口占用问题
//        if (socketIOServer != null) {
//            socketIOServer.stop();
//        }
//        log.info("shutdown redissonClient");
//        RedissonClient redissonClient = SpringContextIniter.getBean(RedissonClient.class);
//        if (redissonClient != null) {
//            redissonClient.shutdown();
//        }
//    }

}
